package com.lagou;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author：dingyuan
 * @date：Created in 2022/1/4 22:18
 * @description：作业三测试类
 * @version: 1.0
 */
public class WorkThreeTest {
    public static void main(String[] args){
        Map<Student, String> stuMap = new HashMap<>();

        stuMap.put(new Student("张三",15),"朝阳区");
        stuMap.put(new Student("李四",18),"海淀区");
        stuMap.put(new Student("王五",15),"密云区");
        System.out.println("========================= 遍历1 ==============================");
        System.out.println(stuMap);

        System.out.println("========================== 遍历2 ==========================");
        Collection<String> values = stuMap.values();
        for (String address:values) {
            System.out.println("学生地址为："+address);
        }

        System.out.println("========================== 遍历3 ========================");
        for (Map.Entry<Student, String> map : stuMap.entrySet()) {
            System.out.println(map);
        }

        System.out.println("========================== 遍历4 =======================");
        for (Student key : stuMap.keySet()) {
            System.out.println(key + ":" + stuMap.get(key));
        }
    }
}
